package com.example.demo.config;

import com.example.demo.model.Dog;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.web.context.annotation.ApplicationScope;
import org.springframework.web.context.annotation.RequestScope;
import org.springframework.web.context.annotation.SessionScope;

@Configuration
public class DogConfig {

    //单例作用域
    @Bean
    @Scope(scopeName = ConfigurableBeanFactory.SCOPE_SINGLETON)
    public Dog singleton(){
        return new Dog();
    }


    //多例作用域
    @Bean
    @Scope(scopeName = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
    public Dog prototypeDog(){
        return new Dog();
    }
    //http 请求
    @Bean
    @RequestScope
    public Dog requestDog(){
        return new Dog();
    }

    /**
     * session 会话
     */
    @Bean
    @SessionScope
    public Dog sessionDog(){
        return new Dog();
    }

    @Bean
    @ApplicationScope
    public Dog applicationDog(){
        return new Dog();
    }




}
